package com.reebake.ideal.security.handler;

import com.reebake.ideal.security.core.AuthenticationFactor;
import com.reebake.ideal.security.core.AuthenticationFactorConvertor;
import com.reebake.ideal.security.entity.QrcodeAuthenticationFactor;
import com.reebake.ideal.security.entity.QrcodeCredential;
import com.reebake.ideal.security.qrcode.QrcodeAuthenticationToken;
import org.springframework.security.core.Authentication;

public class QrcodeAuthenticationFactorConvertor implements AuthenticationFactorConvertor<QrcodeAuthenticationFactor> {
    @Override
    public Class<QrcodeAuthenticationFactor> getFactorType() {
        return QrcodeAuthenticationFactor.class;
    }

    @Override
    public Authentication convert(QrcodeAuthenticationFactor authenticationFactor) {
        return new QrcodeAuthenticationToken(authenticationFactor.getCredential());
    }
}
